package org.softee.functional;

import java.util.concurrent.Executor;

/**
 *
 * @author morten.hattesen@gmail.com
 *
 * @param <F> The type of the payloads being operated on by this Functional
 */
public interface ParallelFunctional<F> extends Functional<F> {
    /**
     * NOTE: After calling this method, any pre-existing Executor will be removed
     * @param threadFactor the number of threads that should be created to perform the parallel tasks.
     * Defaults to number of available CPU cores + 1, suitable for purely CPU bound tasks. Increase for IO bound tasks
     * @return this instance, allowing method chaining
     */
    ParallelFunctional<F> withThreadFactor(float threadFactor);

    /**
     * NOTE: After calling this method, any pre-existing Executor will be removed
     * @param decompositionFactor estimate of the variance of the "computational weight"  of the tasks being processed.
     * 1.0 signifies all tasks having identical weight. 10.0 signifies tasks having a 1:10 computational weight.
     * Never specify values below 1.0.
     * Default value: 2.0.
     * @return this instance, allowing method chaining
     */
    ParallelFunctional<F> withDecompositionFactor(float decompositionFactor);

    /**
     * @param executor the executor to use for computation. If you don't specify, one will be created
     * @return this instance, allowing method chaining
     */
    ParallelFunctional<F> using(Executor executor);
}
